//=================
/**
 * ast节点结构示例
 */
//=================

// clone 3@10 8##12
let res = {
  tag: 'operator',
  params: [
    {
      tag: 'pos',
      left: {
        tag: 'digit',
        value: 3
      },
      right: {
        tag: 'digit',
        value: 10
      },
      operator: '@'
    },
    {
      tag: 'pos',
      left: {
        tag: 'digit',
        value: 8
      },
      right: {
        tag: 'digit',
        value: 12
      },
      operator: '##'
    }
  ],
  operator: 'clone'
};

// 5.1->9
let res = {
  tag: 'assign',
  left: {
    tag: 'dot',
    left: {
      tag: 'digit',
      value: 5
    },
    right: {
      tag: 'digit',
      value: 1
    }
  },
  right: {
    tag: 'digit',
    value: 9
  },
  operator: '->'
};

// 5->StringIsNull@@10
let res = {
  tag: 'assign',
  left: {
    tag: 'digit',
    value: 5
  },
  right: {
    tag: 'assign',
    left: {
      tag: 'word',
      value: 'StringIsNull'
    },
    right: {
      tag: 'digit',
      value: 10
    },
    operator: '@@'
  },
  operator: '->'
};

// 5.id=abc
let res = {
  tag: 'assign',
  left: {
    tag: 'assign',
    left: {
      tag: 'digit',
      value: 5
    },
    right: {
      tag: 'word',
      value: 'id'
    },
    operator: '.'
  },
  right: {
    tag: 'word',
    value: 'abc'
  },
  operator: '='
};

//=================
/**
 * 基本类型结构定义
 */
//=================
let operator = {
  tag: 'operator',
  params: [],
  operator: 'rm',
  children: []
};
// 5.id = 123
let assign = (pos = dot = {
  tag: 'assign | pos | dot',
  left: {},
  right: {},
  operator: '=',
  children: []
});

// literal
let digit = (word = expression = {
  tag: 'digit | word | expression',
  value: {}
});
